home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / DM5.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-10  |  59.7 KB  |  1,831 lines

  1. char hitwall[] = "2 D:hitwa";  /* hit wall sound */
  2. char gate[]    = "2 D:gate0";  /* gate sound */
  3.  
  4.  
  5. #define CH_A_TONE_L     0x00,   /* TONE PERIOD REGS. determines pitch*/  
  6. #define CH_A_TONE_H     0x01,   /* period = 125,000 / freq (Hz) */
  7. #define CH_B_TONE_L     0x02,   /* see page 76 Atari ST TOS */
  8. #define CH_B_TONE_H     0x03,
  9. #define CH_C_TONE_L     0x04,
  10. #define CH_C_TONE_H     0x05,
  11. #define NOISE_PERIOD    0x06,    /* LOW = Thin,static like HIGH = fast rushing (windlike) */
  12. #define ENAB_TONE_NOISE 0x07,    
  13. #define CH_A_VOL_AMP    0x08,
  14. #define CH_B_VOL_AMP    0x09,
  15. #define CH_C_VOL_AMP    0x0a,
  16. #define ENV_PERIOD_L    0x0b,    /* Higher period = more slowly VOL changes and TONES are bell like*/
  17. #define ENV_PERIOD_H    0x0c,    /* lower period  = VOL changes fast and TONES are very raspy! */
  18. #define WAVEFORM        0x0d,    
  19. #define PLACE           0x80,    /* For Ending, or loops */
  20. #define INTO            0x81,
  21. #define INCREMENT_BY
  22. #define UNTIL
  23.  
  24. /* GLOBAL SOUNDS FOR DOSOUND() */
  25.  
  26. static unsigned char wind_sound[]={
  27. CH_A_VOL_AMP     0x0b,
  28. CH_B_VOL_AMP     0x11,
  29. CH_C_VOL_AMP     0x03,
  30. CH_A_TONE_H      0x01,
  31. CH_A_TONE_L      0xff,
  32. CH_B_TONE_H      0xff,
  33. CH_B_TONE_L      0xff,
  34. NOISE_PERIOD     0xff,
  35. ENAB_TONE_NOISE  0x03,
  36. ENV_PERIOD_L     0x22,
  37. ENV_PERIOD_H     0xff,
  38. WAVEFORM         0x0e,                         
  39. PLACE 0x02,INTO 0x12, INCREMENT_BY 0x02, UNTIL 0x25};
  40.  
  41. static unsigned char quiet[] = {
  42. CH_A_VOL_AMP     0x00,
  43. CH_B_VOL_AMP     0x00,
  44. CH_C_VOL_AMP     0x00,
  45. CH_A_TONE_H      0x00,
  46. CH_A_TONE_L      0x00,
  47. CH_B_TONE_H      0x00,
  48. CH_B_TONE_L      0x00,
  49. NOISE_PERIOD     0x00,
  50. ENAB_TONE_NOISE  0x00,
  51. ENV_PERIOD_L     0xff,
  52. ENV_PERIOD_H     0xff,
  53. WAVEFORM         0x00,  
  54. 0xff,0x00};
  55.     
  56.  
  57. static unsigned char rain_sound[]={
  58. CH_A_VOL_AMP     0xff,
  59. CH_B_VOL_AMP     0xff,
  60. CH_C_VOL_AMP     0x03,
  61. CH_A_TONE_H      0xff,
  62. CH_A_TONE_L      0x00,
  63. CH_B_TONE_H      0xff,
  64. CH_B_TONE_L      0x00,
  65. CH_C_TONE_H      0x09,
  66. CH_C_TONE_L      0x00,
  67. NOISE_PERIOD     0xff,
  68. ENAB_TONE_NOISE  0x63,
  69. ENV_PERIOD_L     0x22,
  70. ENV_PERIOD_H     0x11,
  71. WAVEFORM         0x0d,                         
  72. PLACE 0x02,INTO 0x12, INCREMENT_BY 0x02, UNTIL 0x24};
  73.  
  74.  
  75. #define WEAPON -5
  76. #define ARMORY -6
  77. #define GUILD -4
  78. #define SUPPLY -10
  79. #define TOWER -8
  80. #define TAVERN -3
  81. #define ARENA -11
  82. #define DUNGEON -13
  83. #define PALACE -7
  84. #define TEMPLE -1
  85. #define INN -2
  86. #define GATE -9
  87. #define BANK -12
  88. #define DOOR -99
  89. #define WALL 0
  90.  
  91. #define MOVED_LEFT  0         /* for special_move check */
  92. #define MOVED_RIGHT 1
  93. #define MOVED_BACK  2
  94. #define FOREWARD   0x480000           
  95. #define TURN_LEFT  0x520000
  96. #define TURN_RIGHT 0x470000
  97. #define BACK       0x500000
  98. #define LEFT       0x4b0000
  99. #define RIGHT      0x4d0000
  100. #define NOTHING    0x111111
  101.  
  102.  
  103. /* re coding for dungeon module.   1-26-94 
  104.  
  105.   - Implementing Dungeonmaster walls.
  106.  
  107. */
  108.  
  109.  
  110.  
  111.  
  112.  
  113.       /* uses ONLY fncts from there 'h' files*/
  114. #include <gemdefs.h>       /* that it needs. Smart compiler */
  115. #include <osbind.h>
  116. #include <stdio.h>
  117. #include <dungmain.h>
  118. #include <strings.h>
  119. #include <linea.h>
  120.  
  121. #define pos_rnd(t) Random()%(t)   /*returns a number from 0 to (t-1) */
  122.  
  123. char *screen,*back,*temp;    /* double buffering screens */
  124.                        /* back is allocated 32k, 
  125.                           screen = Physbase */
  126.  
  127. int which_screen = 0;  /* if 0 then use 'screen'
  128.                           if 1 then use 'back'
  129.                          For double buffering purposes. */
  130.  
  131.  int  buffer[200];        /* holds the char info for disk loading and saving */
  132.  
  133.  
  134. /* define our templates */
  135. #define CF64    1                 
  136. #define CL       2
  137. #define CR        3
  138. #define ML      4
  139. #define MR      5
  140. #define FL      6
  141. #define FR      7
  142. #define CF1     8
  143. #define CF2     9 
  144. #define CF1_SPECIAL   10
  145. #define CF2_SPECIAL   11
  146. #define MF3211        12
  147. #define MF3212        13
  148. #define MF1611        14
  149. #define MF1612        15
  150. #define MF641        16
  151. #define FF3211        17
  152. #define FF3212        18
  153. #define FF1611        19
  154. #define FF1612        20
  155. #define FF641        21
  156. #define MF3221        22    
  157. #define MF3222        23
  158. #define MF1621        24
  159. #define MF1622        25
  160. #define MF642        26
  161. #define FF3221        27
  162. #define FF3222        28
  163. #define FF1621        29
  164. #define FF1622        30
  165. #define FF642        31
  166. #define ML_GATE       32
  167. #define MR_GATE       33
  168. #define FL_GATE       34
  169. #define FR_GATE       35
  170. #define CL_GATE       36
  171. #define CR_GATE       37
  172. #define REG_R4_FILL   38
  173. #define REG_FAR_FILL  39
  174. #define REG_MED_CLOSE_FILL  40
  175. #define FAR_GATE      41
  176. #define CLOSE_GATE    42
  177. #define EMPTY               0
  178.  
  179. #define OR 7
  180. #define REPLACE 3
  181. int mode;
  182.  
  183.  
  184. int room =1;         /* tells what room your in */
  185. int rect1[4];        /* rectangle of display movement area */
  186. lineaport *theport;              /* a line identifier */
  187. unsigned form[37];   /* for new mouse sprite */
  188.  
  189. int floor = 0;  /* if 0 use floor 1, if 1 use floor 2 */ 
  190.  
  191.  
  192.  
  193. main()
  194.  
  195. {
  196.     MFDB    theMFDB;    /*  Screen definition structure  */
  197.     MFDB    tempMFDB;
  198.     MFDB    backgroundMFDB;  /* to save background for gates */
  199.  
  200.  
  201.     /* define background screens. We need 
  202.        1 for Templates
  203.        2,3,4 for monsters?? */
  204.  
  205.     char *scr1,                   /* wall templates 1 */
  206.          *scr2,                      /* wall templates 2 */
  207.          *scr3,                      /* WALL templates 3*/
  208.          *scr4,                      /* wall templates 4*/
  209.          *scr5,                   /* floor template 1*/
  210.          *scr6,                   /* floor template 2*/
  211.          *scr7,
  212.          *gate_back;              /* memory to store background info*/
  213.  
  214.       /* used to be in main() now global */
  215.     int realtime=4;/* we'l do a realtime%4 */  
  216.     int off();
  217.     int pxyarray[8],      /* for vrocopyfm */
  218.         enc_true;
  219.     long hold_addr;
  220.     int xs1,ys1,xs2,ys2,xd1,yd1,yd2,xd2;
  221.     int colors[2];       
  222.     int f,g,lll;
  223.     char dis_map;
  224.     int savex,savey;
  225.     int can_move;    /* returned from move() if 1 = you can move that way
  226.                                                 0 = its blocked */
  227.                      
  228.     theport = a_init();            /* invoke a line driver */
  229.  
  230.       appl_init();
  231.  
  232.          a_hidemouse();
  233.  
  234.  
  235.  
  236.    x =5; y=0;
  237.    dir = 'N';
  238.    pxyarray[4]=7; pxyarray[4]=4; pxyarray[4]=38; pxyarray[4]=144;
  239.    
  240.     rect1[0]= 7;       /* area to 'black out' before we do screen copy */
  241.     rect1[1]= 144;     /* it's the movement display region */
  242.     rect1[2]= 230;
  243.     rect1[3]= 9;
  244.  
  245.  
  246.     appl_init();
  247.     handle = open_workstation(&theMFDB);  /*set up screen MFDB */
  248.  
  249. vsf_color(handle,15);  /* white */
  250. vsf_interior(handle,1);
  251.  
  252.  
  253.    screen= malloc(32768+256);  /*allocate memory for 2nd screen */
  254.     if ((long)screen & 0xff)
  255.       screen = screen + (0x100 - (long)screen & 0xff);
  256.  
  257.   
  258.    back = malloc(32768+256);  /*allocate memory for 2nd screen */
  259.     if ((long)back & 0xff)
  260.       back = back + (0x100 - (long)back & 0xff);
  261.       
  262.    scr1 = malloc(32768+256);  /*allocate memory for 2nd screen */
  263.     if ((long) scr1 & 0xff)
  264.       scr1 = scr1 + (0x100 - (long)scr1 & 0xff);
  265.       
  266.     scr2 = malloc(32768+256);  /*allocate memory for 2nd screen */
  267.     if ((long) scr2 & 0xff)
  268.       scr2 = scr2 + (0x100 - (long)scr2 & 0xff);
  269.   
  270.     scr3 = malloc(32768+256);  /*allocate memory for 2nd screen */
  271.     if ((long) scr3 & 0xff)
  272.       scr3 = scr3 + (0x100 - (long)scr3 & 0xff);
  273.     
  274.     scr4 = malloc(32768+256);  /*allocate memory for 2nd screen */
  275.     if ((long) scr4 & 0xff)
  276.       scr4 = scr4 + (0x100 - (long)scr4 & 0xff);
  277.    
  278.     scr5 = malloc(32768+256);  /*allocate memory for 2nd screen */
  279.     if ((long) scr5 & 0xff)
  280.       scr5 = scr5 + (0x100 - (long)scr5 & 0xff);
  281.     
  282.     scr6 = malloc(32768+256);  /*allocate memory for 2nd screen */
  283.     if ((long) scr6 & 0xff)
  284.       scr6 = scr6 + (0x100 - (long)scr6 & 0xff);
  285.     
  286.    scr7 = malloc(32768+256);  /*allocate memory for 2nd screen */
  287.     if ((long) scr7 & 0xff)
  288.       scr7 = scr7 + (0x100 - (long)scr7 & 0xff);
  289.   
  290.  
  291.     gate_back = malloc(32768+256);  /*allocate memory for 2nd screen */
  292.     if ((long) gate_back & 0xff)
  293.       gate_back = gate_back + (0x100 - (long)gate_back & 0xff);
  294.  
  295.      /* only 6 main physical screens in memory */
  296.  
  297. set_up1();             /* init rooms 1-3 */
  298. /*set_up2();             init rooms 101-247 */
  299. init(12,"level1.dat");         /* init map etc.. */
  300.  
  301.     tempMFDB.fd_w    = theMFDB.fd_w ; /* 320 pixels wide*/
  302.     tempMFDB.fd_h       = theMFDB.fd_h ; /*200 pixels high */
  303.     tempMFDB.fd_wdwidth = theMFDB.fd_wdwidth ; /*16 words wide*/
  304.     tempMFDB.fd_stand = theMFDB.fd_stand ; /* raster coords.*/
  305.     tempMFDB.fd_nplanes = theMFDB.fd_nplanes; /*low rez has 4 planes */
  306.       
  307.     /* holds the background pic for gate movement */
  308.     backgroundMFDB.fd_w       = theMFDB.fd_w; /*  pixels wide*/
  309.     backgroundMFDB.fd_h       = theMFDB.fd_h ; /*  pixels high*/
  310.     backgroundMFDB.fd_wdwidth = theMFDB.fd_wdwidth;  /*fdw divided by 16 */
  311.     backgroundMFDB.fd_stand = theMFDB.fd_stand; /* raster coords.*/
  312.     backgroundMFDB.fd_nplanes = theMFDB.fd_nplanes; /*low rez has 4 planes */
  313.  
  314.  
  315.  
  316.  
  317.  read_stuff(pix1,scr1,1); /* WALLS 1*/        /* read back screen into memory */
  318.  read_stuff(pix2,scr2,1); /* walls 2*/
  319.  read_stuff(pix3,scr3,1); /* walls 3*/
  320.  read_stuff(pix4,scr4,1); /* walls 4*/
  321.  read_stuff(pix5,scr5,1);  /*FLOOR1*/
  322.  read_stuff(pix6,scr6,1);  /*FLOOR 2 */
  323.  read_stuff(pix7,scr7,1);  /*GATES*/
  324.  
  325.  
  326.  
  327. /* find screen base */
  328. /*
  329. screen = (char *)Physbase(); 
  330. */
  331. read_stuff(title,back,1);  /* read main title screen onto the screen*/
  332. read_stuff(title,screen,1); /* read main title screen onto back screen also. */
  333. Setscreen(back,screen,-1);
  334.  
  335. /* set the destination MFDB to the back screen, and the backgroundMFDB
  336.    to the gate_back area */
  337. theMFDB.fd_addr = (long) back;    
  338. backgroundMFDB.fd_addr = (long) gate_back;
  339.  
  340.  
  341.  
  342.  
  343. Setpalette(newpal);        /* tel sys to use these colors! */
  344.  
  345. graf_mouse(3,form);
  346. a_showmouse();
  347.  
  348.  
  349.  
  350. /*main loop */
  351.  start();
  352.  
  353. colors[0]=1;
  354. colors[1]=0;
  355.  
  356. /*
  357. events();
  358. */
  359.  
  360.                                       /* these are constant ! */
  361.  pxyarray[5] = 9; pxyarray[7] = 144;  /* destination y coords */
  362. command = NOTHING;
  363. display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);
  364. Vsync();
  365.  
  366.  
  367.  
  368. /*
  369. display_user_stats();
  370. */ 
  371.  
  372.  
  373.  do
  374.      {
  375.       
  376.   /* get here, key was pressed */    
  377.       command = Bconin(2);
  378.        if(command == FOREWARD)  /* Foreward */
  379.             {
  380.              can_move=move();
  381.              if(can_move)
  382.               display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);
  383.  
  384.             }
  385.        if(command == TURN_LEFT)   /* TURN left */
  386.             {
  387.              look();
  388.              display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);      
  389.             }
  390.        if (command == TURN_RIGHT)   /*TURN Right */
  391.             {
  392.              look();
  393.              display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);
  394.             
  395.             }
  396.        if (command == BACK)   /*back*/
  397.             {
  398.              can_move=special_move(MOVED_BACK);
  399.              if(can_move)
  400.               display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);
  401.             
  402.             }
  403.      
  404.          if (command == LEFT)   /*GO LEFT(sideways)*/
  405.             {
  406.              can_move=special_move(MOVED_LEFT);
  407.              if(can_move)
  408.               display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);
  409.              
  410.             }
  411.      
  412.         if (command == RIGHT)   /*GO RIGHT(sideways)*/
  413.             {
  414.              can_move=special_move(MOVED_RIGHT);
  415.              if(can_move)
  416.               display(&theMFDB,&tempMFDB,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,&backgroundMFDB);
  417.             
  418.             }
  419.  
  420.  
  421.  
  422.   check_for_closed_gate(&tempMFDB,&theMFDB,&backgroundMFDB,pxyarray,scr7);
  423.  
  424.  
  425.   
  426. }while (1);        /* 4-ever loop.... */  
  427.  
  428.     v_clsvwk(handle);
  429.     appl_exit();
  430. }
  431.  
  432.  
  433.  
  434. /*************************************************************/
  435. /* This function     - checks the dir you are facing and tests
  436.                        to see if you are at a closed gate    
  437.  
  438.    Algorithm:     map[room].dir holds values. If this value is:
  439.  
  440.                     0   -- a wall, you cant move that way
  441.                    >0   -- designates which room you'll end up in 
  442.                            if you decide to move that direction
  443.                    <0   -- Denotes a CLOSED gate. And this negative
  444.                            number is the room number of the room
  445.                            beyond the gate!!!!
  446.  
  447.                   We will check the value of map[room] for every
  448.                   direction. If a negative value is found and 
  449.                   we're facing it, lets call the gate animation
  450.                   code and then set map[room].dir to the room 
  451.                   number after the gate.( * by -1 of course!! ) 
  452.                   Finally we will set the roomrec[room].dir.Field4
  453.                   to EMPTY so that the gate will not be displayed again
  454.                  
  455. */
  456.  
  457. check_for_closed_gate(tempMFDB,theMFDB,backgroundMFDB,pxyarray,scr7)
  458. MFDB *theMFDB,
  459.      *tempMFDB,
  460.      *backgroundMFDB;
  461. int pxyarray[];
  462. char *scr7;
  463.  
  464. {
  465.  int lll,
  466.      closed = 0;   /* if set to 1, we found a closed gate the 
  467.                       direction we were facing */
  468.  
  469.   if(map[room].n < 0 && dir == 'N') closed =1; /* CHECK for closed gate*/
  470.    if(map[room].s < 0 && dir == 'S')closed =1; /* denoted by a negative #*/
  471.    if(map[room].e < 0 && dir == 'E')closed =1;
  472.   if(map[room].w < 0 && dir == 'W') closed =1;
  473.  
  474.  
  475.    if( closed )   /* if closed = 1 then lets animate gate and
  476.                      set map[room].dir = room # after gate */
  477.      {
  478.          /* copy the region that the gate will cover into 
  479.             the gate_back, or the backgroundMFDB store it 
  480.             at coords (71,31)(166,112) using REPLACE mode */
  481.         
  482.   
  483.    /* when we 'built' the scene, if we were at a CLOSE ,CLOSED gate
  484.       we copied regions 1,2,3,5,6,7 then WE saved the area
  485.       that will be behind the gate in backgroundMFDB
  486.       then we display the gate (region4)
  487.    */
  488.  
  489.  
  490.   for(lll=0;lll<=2;lll++)
  491. {
  492.  
  493.      tempMFDB->fd_addr = (long) scr7;  /* scr that holds gate.pc1 */
  494.   
  495.      /* recopy area behind the gate....*/
  496.      /* source coords */
  497.      pxyarray[0]=71; pxyarray[1]=31; pxyarray[2]=166; pxyarray[3]=112;    
  498.      /* dest coords  */
  499.      pxyarray[4]=71; pxyarray[5]=31; pxyarray[6]=166; pxyarray[7]=112;    
  500.      /* do the copy: theMFDB is the DEST, backgroundMFDB is the SOURCE*/
  501.      vro_cpyfm(handle,REPLACE,pxyarray,backgroundMFDB,theMFDB);     
  502.  
  503.  
  504.      pxyarray[4] = 71;                /* the destination coords */
  505.      pxyarray[6] = 166;
  506.      pxyarray[5] = 32; pxyarray[7]=112;
  507.  
  508.     
  509.   switch(lll)
  510.    {
  511.       
  512.     case 0:  
  513.      pxyarray[0]=0; pxyarray[1]=81; pxyarray[2]=95; pxyarray[3]=160;
  514.     vro_cpyfm(handle,4,pxyarray,tempMFDB,theMFDB);  /* copy wholescreens */
  515.     pxyarray[0]=96; pxyarray[1]=81; pxyarray[2]=191; pxyarray[3]=160;
  516.     vro_cpyfm(handle,7,pxyarray,tempMFDB,theMFDB);  /* copy wholescreens */
  517.     break;
  518.  
  519.     case 1:  
  520.      pxyarray[0]=205; pxyarray[1]=0; pxyarray[2]=300; pxyarray[3]=79;
  521.     vro_cpyfm(handle,4,pxyarray,tempMFDB,theMFDB);  /* copy wholescreens */
  522.     pxyarray[0]=206; pxyarray[1]=84; pxyarray[2]=301; pxyarray[3]=163;
  523.     vro_cpyfm(handle,7,pxyarray,tempMFDB,theMFDB);  /* copy wholescreens */
  524.     break;
  525.  
  526.    } /* end of switch */
  527.  invoke_tsr(gate);
  528.   pause(15);
  529.  
  530.  
  531.    } /* end of for */
  532.  
  533.     /* lets set the map[room].dir = room number. This is so
  534.        we denote the gate is open and you can pass thru it to 
  535.        that room!  NOTE: The number is negative and it just
  536.        happens to be the room # thats beyond the gate. So mult
  537.        by -1 to make it positive!!(nice trick..) 
  538.  
  539.        BUT:  We must take in account that there are 2 ways to 
  540.              pass through a gate. So we must update 2 room's
  541.              map[] data structure. It's complicted code, but
  542.              just follow through it..
  543.  
  544.              example: lvl 1 at room 12 if facing south there is
  545.                       a gate. If we open it we must update 
  546.                       map[12].s AND map[23].n!!!
  547.  
  548.                       The first one is easy. map[room].dir...
  549.                       the next one takes some effort.
  550.                       map[map[map[room].s].s].n = ...  
  551.  
  552.      We must also set Field4 of the roomrec data struct to EMPTY
  553.      because it is this data that tells our builder engine what
  554.      to display. If a gate went up, we need to modify roomrec
  555.      so that it will not get displayed again thank you...*/
  556.  
  557.    if(dir == 'N') 
  558.      {       map[room].n = (-1 * map[room].n);
  559.              map[map[map[room].n].n].s = (-1 * map[map[map[room].n].n].s);
  560.              
  561.              roomrec[room].N.Field4 = EMPTY;
  562.              roomrec[map[room].s].N.Field4 = EMPTY;
  563.              roomrec[map[map[room].n].n].S.Field4 = EMPTY;
  564.              roomrec[map[map[map[room].n].n].n].S.Field4 = EMPTY;
  565.  
  566.     }  
  567.    if(dir == 'S')
  568.      {       map[room].s = (-1 * map[room].s);  
  569.              map[map[map[room].s].s].n = (-1 * map[map[map[room].s].s].n);
  570.          
  571.             roomrec[room].S.Field4 = EMPTY;  
  572.             roomrec[map[room].n].S.Field4 = EMPTY;
  573.              roomrec[map[map[room].s].s].N.Field4 = EMPTY;
  574.              roomrec[map[map[map[room].s].s].s].N.Field4 = EMPTY;
  575.  
  576.     }
  577.    if(dir == 'E') 
  578.      {       map[room].e = (-1 * map[room].e);
  579.              map[map[map[room].e].e].w = (-1 * map[map[map[room].e].e].w);
  580.            
  581.              roomrec[room].E.Field4 = EMPTY;
  582.              roomrec[map[room].w].E.Field4 = EMPTY;
  583.              roomrec[map[map[room].e].e].W.Field4 = EMPTY;
  584.              roomrec[map[map[map[room].e].e].e].W.Field4 = EMPTY;
  585.     
  586.  
  587.      }  
  588.    if(dir == 'W') 
  589.      {       map[room].w = (-1 * map[room].w);  
  590.              map[map[map[room].w].w].e = (-1 * map[map[map[room].w].w].e);
  591.      
  592.              roomrec[room].W.Field4 = EMPTY;
  593.              roomrec[map[room].e].W.Field4 = EMPTY;
  594.              roomrec[map[map[room].w].w].E.Field4 = EMPTY;
  595.              roomrec[map[map[map[room].w].w].w].E.Field4 = EMPTY;
  596.  
  597.      }
  598.  
  599. } /* end of if room == 4*/
  600.  
  601. } /* end of fnct */
  602.  
  603. /*************************************************************/
  604. /*  This function    - creates the map to move around in
  605.                      - reads map data from file ROOM.DAT
  606.                      - sets your starting position 
  607.  
  608.                        0 - Cant move that way (Wall)
  609.                    pos # - Room you'll goto 
  610.                    neg # - Loads up an establishment 
  611.                     -1 temple
  612.                     -2 inn
  613.                     -3 tavern
  614.                     -4 guild
  615.                     -5 weapon
  616.                     -6 armor
  617.                     -7 castle
  618.                     -8 tower
  619.                     -9 outside, exit city          
  620.                     -999 enter a house(knock down door)     */
  621.  
  622.  init(MAX_X,datafile)
  623.  int MAX_X;  /* holds max x value of level you are reading in */
  624.  char *datafile; /* hold the text file to read the room data from */
  625.   
  626.  
  627.    /* room holds    room#,n,s,e,w
  628.                     if n,s,e,w = 0 then its a wall and you can not 
  629.                                    go that way,
  630.                     else n,s,e,w = room # you'll be in if you go that way */
  631.  
  632. {
  633.     char in;
  634.    FILE *ifp;
  635.    char array[5];         /* at most a max of 3 numbers xxx+null */
  636.    int number;            /* stores converted number */
  637.    int xo=0,yo=0;
  638.    int type=0;            /* if =0 store room
  639.                                  1        n
  640.                                  2        s
  641.                                  3        e
  642.                                  4        w */
  643.    int room = 1; /* start at room 1 */
  644.  
  645.  
  646.    
  647.    ifp = fopen(datafile,"r");        /* r means read only mode */
  648.     if( ifp == NULL) {printf("Error opening room.dat--\n"); exit(1);}
  649.      while( (fgets(array,5,ifp) !=NULL))
  650.       {                /* number read is placed in array . terminated w/  /0 */
  651.          number = atoi(array);      /* converts string to int */
  652.          /* printf("number read:%d\n",number);*/
  653.          if(type ==0)
  654.           {
  655.           map[room].room = number;    /* store it */
  656.          /*printf("storing room #:%d\n",map[yo][xo]);*/
  657.           }
  658.   
  659.           if(type==1)
  660.             {
  661.              map[room].n = number;    /* store it */
  662.             /* printf("storing north:%d\n",map[yo][xo].n);*/           
  663.             }
  664.         if(type==2)
  665.             {
  666.              map[room].s = number;    /* store it */
  667.              /*printf("storing south:%d\n",map[yo][xo].s);  */    
  668.             }
  669.            if(type==3)
  670.            {
  671.            map[room].e = number;    /* store it */
  672.            /* printf("storing east:%d\n",map[yo][xo].e);      */     
  673.             }
  674.          if(type==4)
  675.          {
  676.                map[room].w = number;    /* store it */
  677.          /*  printf("storing west:%d\n",map[yo][xo].w);*/
  678.             }
  679.  
  680.  
  681.          type++;
  682.          if( type > 4)
  683.            {
  684.             /* printf("#,and dirs done for room\n");*/
  685.              type = 0;     /* if > 4, reset */
  686.              room++; /* increase room # */
  687.            }
  688.           }       /* end of while */
  689.  
  690.    fclose(ifp);
  691.  
  692.   
  693.    flags.which_pal = 0;   /* start w/ main palette */
  694.   
  695. }
  696.    
  697.  
  698. /*******************/
  699.  
  700.   look()
  701.    
  702.   
  703.  
  704.  {
  705.    int ret;
  706.     /*v_gtext(handle,1,36,"in look");*/
  707.     
  708.  
  709.    switch(dir)
  710.     {
  711.      case 'N' : {
  712.                   if(command == 0x520000)
  713.                   dir = 'W';
  714.                   if(command == 0x470000)
  715.                   dir = 'E';
  716.                   break;
  717.                 }   
  718.  
  719.      case 'S' : {
  720.                   if(command == 0x520000)
  721.                   dir = 'E';
  722.                   if(command == 0x470000)
  723.                   dir = 'W';
  724.                   break;
  725.                 }   
  726.      case 'E' : {
  727.                   if(command == 0x520000)
  728.                   dir = 'N';
  729.                   if(command == 0x470000)
  730.                   dir = 'S';
  731.                   break;
  732.                 }      
  733.      case 'W' : {
  734.                   if(command == 0x520000)
  735.                   dir = 'S';
  736.                   if(command == 0x470000)
  737.                   dir = 'N';
  738.                   break;
  739.                 }
  740.             }  /*end of case*/
  741.       /*v_gtext(handle,1,36,"         ");*/
  742.  
  743.     } /*end of funct*/
  744.  
  745. /*************************************************************/
  746. /* this function will: check for 'special move' and if valid
  747.                        it will update the room you are in.
  748.  
  749.    A special move is a sideways move left or right
  750. */
  751. special_move(direction)
  752. int direction;  /* if 0 you moved left 
  753.                    if 1 you tried to move right 
  754.                    if 2 you tried to move backwards*/
  755.  
  756.    {
  757.     int blocked = 0;
  758.                                      /* clear our 'door is near' mssg */
  759.       /*  v_gtext(handle,6,83,"                      ");*/
  760.  
  761.      if( direction == MOVED_LEFT )
  762.       {
  763.            switch(dir)
  764.                      {
  765.                       case 'N': { 
  766.                                 if(map[room].w <= 0)
  767.                                 blocked = 1;
  768.                                   else
  769.                                    room = map[room].w;  /* goto the room @ the north*/
  770.                                   break;
  771.                                    }
  772.                       case 'S': { 
  773.                                 if(map[room].e <= 0)
  774.                                 blocked = 1;
  775.                                   else
  776.                                    room = map[room].e;  /* goto the room @ the north*/
  777.                                   break;
  778.                                    }
  779.                       case 'E': { 
  780.                                 if(map[room].n <= 0)
  781.                                 blocked = 1;
  782.                                   else
  783.                                    room = map[room].n;  /* goto the room @ the north*/
  784.                                   break;
  785.                                    }
  786.                       case 'W': { 
  787.                                 if(map[room].s <= 0)
  788.                                 blocked = 1;
  789.                                   else
  790.                                    room = map[room].s;  /* goto the room @ the north*/
  791.                                   break;
  792.                                    }
  793.                } /*end of switch*/
  794.             } /* end of IF try to go left */
  795.  
  796.      if( direction == MOVED_RIGHT )
  797.       {
  798.            switch(dir)
  799.                      {
  800.                       case 'N': { 
  801.                                 if(map[room].e <= 0)
  802.                                 blocked = 1;
  803.                                   else
  804.                                    room = map[room].e;  /* goto the room @ the north*/
  805.                                   break;
  806.                                    }
  807.                       case 'S': { 
  808.                                 if(map[room].w <= 0)
  809.                                 blocked = 1;
  810.                                   else
  811.                                    room = map[room].w;  /* goto the room @ the north*/
  812.                                   break;
  813.                                    }
  814.                       case 'E': { 
  815.                                 if(map[room].s <= 0)
  816.                                 blocked = 1;
  817.                                   else
  818.                                    room = map[room].s;  /* goto the room @ the north*/
  819.                                   break;
  820.                                    }
  821.                       case 'W': { 
  822.                                 if(map[room].n <= 0)
  823.                                 blocked = 1;
  824.                                   else
  825.                                    room = map[room].n;  /* goto the room @ the north*/
  826.                                   break;
  827.                                    }
  828.                } /*end of switch*/
  829.             } /* end of IF try to go right */
  830.      if( direction == MOVED_BACK )
  831.       {
  832.            switch(dir)
  833.                      {
  834.                       case 'N': { 
  835.                                 if(map[room].s <= 0)
  836.                                 blocked = 1;
  837.                                   else
  838.                                    room = map[room].s;  /* goto the room @ the north*/
  839.                                   break;
  840.                                    }
  841.                       case 'S': { 
  842.                                 if(map[room].n <= 0)
  843.                                 blocked = 1;
  844.                                   else
  845.                                    room = map[room].n;  /* goto the room @ the north*/
  846.                                   break;
  847.                                    }
  848.                       case 'E': { 
  849.                                 if(map[room].w <= 0)
  850.                                 blocked = 1;
  851.                                   else
  852.                                    room = map[room].w;  /* goto the room @ the north*/
  853.                                   break;
  854.                                    }
  855.                       case 'W': { 
  856.                                 if(map[room].e <= 0)
  857.                                 blocked = 1;
  858.                                   else
  859.                                    room = map[room].e;  /* goto the room @ the north*/
  860.                                   break;
  861.                                    }
  862.                } /*end of switch*/
  863.             } /* end of IF try to go back */
  864.  
  865.  
  866.   if(blocked)
  867.    {
  868.    
  869.  
  870.      invoke_tsr( hitwall );  
  871.        /* if blocked return a 0 */
  872.        return(0);
  873.  
  874.    }  
  875.   
  876.     /* else return  a 1*/
  877.     return(1);
  878.  
  879.  
  880.     } /*end of funct*/
  881.  
  882.  
  883.  
  884.  
  885.  
  886. /**************************************************************/
  887. /* This function will :
  888.  
  889.                  - Check to see if you move is valid
  890.                  - If so it will move you in the dir 
  891.                    you are facing and adjust your new
  892.                    position accordingly                    
  893.                  - load up estabs.pic if needed. and change 
  894.                    the palette, it will save the 3 changed colors
  895.                    in col1,col2,col3 and replace them at end of this
  896.                    module
  897. */
  898. move()
  899.   
  900.    { 
  901.     int blocked = 0;
  902.                                      /* clear our 'door is near' mssg */
  903.       /*  v_gtext(handle,6,83,"                      ");*/
  904.  
  905.       switch(dir)
  906.      {
  907.      case 'N': {
  908.                
  909.                 if(map[room].n <= 0)
  910.                 blocked = 1;
  911.                   else
  912.                    room = map[room].n;  /* goto the room @ the north*/
  913.                   break;
  914.                }
  915.      case 'S': {
  916.                 
  917.                 if(map[room].s <= 0)
  918.                 blocked = 1;
  919.                  else 
  920.                   room = map[room].s;  /* goto room at the S */
  921.                   break;
  922.                }
  923.      case 'E': {
  924.                
  925.                 if(map[room].e <= 0)
  926.                 blocked = 1;
  927.                 else
  928.                   room = map[room].e;
  929.                   break;
  930.                }
  931.      case 'W': {
  932.                 
  933.                 if(map[room].w <= 0) blocked = 1;
  934.                  else
  935.                    room = map[room].w;
  936.                   break;
  937.                } 
  938.        } /*end of switch*/
  939.   if(blocked)
  940.    {
  941.    
  942.     invoke_tsr( hitwall );  
  943.        /* if blocked return a 0 */
  944.        return(0);
  945.  
  946.    }  
  947.   
  948.     /* else return  a 1*/
  949.     return(1);
  950.  
  951.  
  952.     } /*end of funct*/
  953.  
  954.  
  955.  
  956.  
  957. /*******************************************/
  958. /**************************************************************/
  959.  
  960. clean()
  961.   
  962.    {
  963.       loc = map[room].room;
  964.    }
  965.  
  966.  
  967. /*******************/
  968.  
  969. /**************************************************************/
  970.  
  971.  
  972. /* This funct :   - sets up a new font
  973.                   - inits the hit roll table
  974.                   - inits the AES and Aline
  975.                   - inits the char stats 
  976.                   - inits the virtual memory hit_table so first 
  977.                     5 cells are set to 1, all others are 0 
  978.                   - turns off keyclick so Dosound() will not be 
  979.                     interrupted */
  980. start()
  981.  
  982. {
  983.     int color,catch;
  984.     int off();
  985.     int cellh,cellw,charh,charw;
  986.     int number1 = 19,pp;
  987.     char disk;
  988.       
  989.  
  990.  
  991.  /* hit roll table goes here */      /* the HRT...hmm put it in init! */
  992.  for(pp=0;pp<16;pp++)
  993.   {
  994.     hrt[pp] = number1;
  995.     number1--;
  996.   }
  997.  
  998.  
  999.  mhrt[0]=20;    /* users ac will go from 0-15 w/ 0 being lowest! */
  1000.  mhrt[1]=20;
  1001.  mhrt[2]=20;
  1002.  mhrt[3]=20;
  1003.  mhrt[4]=20;
  1004.  mhrt[5]=20;
  1005.  mhrt[6]=19;
  1006.  mhrt[7]=18;
  1007.  mhrt[8]=17;
  1008.  mhrt[9]=16;
  1009.  mhrt[10]=15;
  1010.  mhrt[11]=14;
  1011.  mhrt[12]=13;
  1012.  mhrt[13]=12;
  1013.  mhrt[14]=11;
  1014.  mhrt[15]=10;
  1015.  
  1016.  
  1017.     color = 7;                   /*set text color */
  1018.     vst_color(handle,color);
  1019.  
  1020.    runner=1;      
  1021.    mon_alive =1;
  1022.    char_alive =1;  /* if either is set to 0, encounter ends */
  1023.    
  1024. /*
  1025.    loadchar(buffer);
  1026.    dir = user.dir;    set the map coords to place where you saved
  1027.    x   = user.x_loc;
  1028.    y   = user.y_loc;*/
  1029.   
  1030. /*
  1031. for(pp=0;pp<10;pp++)
  1032.  user.backpack[pp]=-1;*/       /* initally set backpack empty */
  1033. for(pp=0;pp<max_items;pp++)  /* set up weapon damnage point lookup */
  1034.  unique_item[pp].points = pp;
  1035.  
  1036. /*
  1037. strcpy(unique_item[0].name,"Dagger");
  1038. strcpy(unique_item[1].name,"Club");
  1039. strcpy(unique_item[2].name,"Staff");
  1040. strcpy(unique_item[3].name,"War Hammer");
  1041. strcpy(unique_item[4].name,"Short Sword");
  1042. strcpy(unique_item[5].name,"Short Bow");
  1043. strcpy(unique_item[6].name,"Pole Arm");
  1044. strcpy(unique_item[7].name,"Halaberd");
  1045. strcpy(unique_item[8].name,"Long Bow");
  1046. strcpy(unique_item[9].name,"Long Sword");
  1047. strcpy(unique_item[10].name,"Battle Axe");
  1048. strcpy(unique_item[11].name,"Bastard Sword");
  1049. strcpy(unique_item[12].name,"Magical Staff");
  1050. strcpy(unique_item[13].name,"Magical Bow");
  1051. strcpy(unique_item[14].name,"Mithril Sword");
  1052. strcpy(unique_item[15].name,"Aurraks Staff");
  1053. strcpy(unique_item[16].name,"Conir Balde");
  1054.  
  1055. */
  1056.  
  1057. /* up to 50 of em , if want to make bigger, change size in maindefs.h */
  1058.  
  1059.  
  1060. /* set up street names, intersections */
  1061.  
  1062. /*
  1063. intersection[0].room = 1;
  1064. strcpy(intersection[0].street_name," Herald Street");
  1065. intersection[1].room = 6;
  1066. strcpy(intersection[1].street_name," Herald Street");
  1067. intersection[2].room = 9;
  1068. strcpy(intersection[2].street_name," Herald Street");
  1069. intersection[3].room = 12;
  1070. strcpy(intersection[3].street_name," Herald Street");
  1071. intersection[4].room = 15;
  1072. strcpy(intersection[4].street_name," Herald Street");
  1073. intersection[5].room = 17;
  1074. strcpy(intersection[5].street_name," Herald Street");
  1075. intersection[6].room = 25;
  1076. strcpy(intersection[6].street_name," Herald Street");
  1077.  
  1078. intersection[7].room = 19;
  1079. strcpy(intersection[7].street_name,"  an alcove   ");
  1080.  
  1081. intersection[8].room = 18;
  1082. strcpy(intersection[8].street_name," a side street");
  1083. intersection[9].room = 49;
  1084. strcpy(intersection[9].street_name," a side street");
  1085. intersection[10].room = 164;
  1086. strcpy(intersection[10].street_name," a side street");
  1087. intersection[11].room = 216;
  1088. strcpy(intersection[11].street_name," a side street");
  1089.  
  1090. intersection[12].room = 69;
  1091. strcpy(intersection[12].street_name," Oldham Street");
  1092. intersection[13].room = 155;
  1093. strcpy(intersection[13].street_name," Oldham Street");
  1094. intersection[14].room = 198;
  1095. strcpy(intersection[14].street_name," Oldham Street");
  1096. intersection[15].room = 222;
  1097. strcpy(intersection[15].street_name," Oldham Street");
  1098.  
  1099. intersection[16].room = 163;
  1100. strcpy(intersection[16].street_name,"secret passage");
  1101.  
  1102. intersection[17].room = 220;
  1103. strcpy(intersection[17].street_name," Valkerye Way ");
  1104. intersection[18].room = 235;
  1105. strcpy(intersection[18].street_name," Valkerye Way ");
  1106. intersection[19].room = 207;
  1107. strcpy(intersection[19].street_name," Valkerye Way ");
  1108. intersection[20].room = 195;
  1109. strcpy(intersection[20].street_name," Valkerye Way ");
  1110.  
  1111. intersection[21].room = 37;
  1112. strcpy(intersection[21].street_name,"   a street   ");
  1113. intersection[22].room = 21;
  1114. strcpy(intersection[22].street_name,"   a street   ");
  1115. intersection[23].room = 22;
  1116. strcpy(intersection[23].street_name,"   a street   ");
  1117. intersection[24].room = 72;
  1118. strcpy(intersection[24].street_name,"   a street   ");
  1119. intersection[25].room = 44;
  1120. strcpy(intersection[25].street_name,"   a street   ");
  1121.  
  1122. intersection[26].room = 82;
  1123. strcpy(intersection[26].street_name,"  Gran Platz  ");
  1124. intersection[27].room = 128;
  1125. strcpy(intersection[27].street_name,"  Gran Platz  ");
  1126. intersection[28].room = 149;
  1127. strcpy(intersection[28].street_name,"  Gran Platz  ");
  1128.  
  1129. intersection[29].room = 144;
  1130. strcpy(intersection[29].street_name,"  Chariot Way ");
  1131. intersection[30].room = 156;
  1132. strcpy(intersection[30].street_name,"  Chariot Way ");
  1133. intersection[31].room = 199;
  1134. strcpy(intersection[31].street_name,"  Chariot Way ");
  1135. intersection[32].room = 194;
  1136. strcpy(intersection[32].street_name,"  Chariot Way ");
  1137.  
  1138. intersection[33].room = 190;
  1139. strcpy(intersection[33].street_name,"   an alley   ");
  1140. intersection[34].room = 161;
  1141. strcpy(intersection[34].street_name,"   an alley   ");
  1142.  
  1143.  
  1144. */
  1145.  
  1146. /*kill key repeat */
  1147. Kbrate(255,255);  
  1148.  
  1149. /* turn off keyclick*/ 
  1150.  
  1151. Supexec( off );
  1152.  
  1153. /* load font, font must be in INtel format!!!! */
  1154. /*
  1155. v_gtext(handle,6,11,"Do you want to use the");
  1156. v_gtext(handle,6,19,"(C)urrent font or the");
  1157. v_gtext(handle,6,27,"(G)ame's font?");
  1158. do
  1159. {
  1160. disk = Bconin(2);
  1161. }while(disk != 'G' && disk != 'g' && disk != 'C' && disk != 'c');
  1162.  
  1163. if(disk == 'G' || disk == 'g')
  1164. {
  1165. vst_load_fonts(handle,0);*/  /*always 0 */
  1166. /*vst_font(handle,50);*/   /*id of goth_i8.fnt is 50 */
  1167. /*}*/
  1168.  
  1169. /* call funct to load PLAYER as a TSR*/
  1170. load_player_as_tsr();     /* will load player (ie.play.prg) as tsr */
  1171.  
  1172. /*
  1173. assign_monsters(); *//* assign the monsters!! */
  1174.  
  1175. /*
  1176. do
  1177. {
  1178. if( (catch=Fopen("appla",0)) < 0 )
  1179.   {
  1180.       v_gtext(handle,6,11,"Please insert Disk 2  ");
  1181.       v_gtext(handle,6,19,"into the current drive");
  1182.       v_gtext(handle,6,27,"and press any key.");
  1183.       disk = Bconin(2);
  1184.       
  1185.   }
  1186.     Fclose(catch);
  1187. } while(catch < 0 );
  1188. */
  1189.  
  1190. /* finally, lets display the constant stuff... */
  1191.  
  1192. /*
  1193. v_gtext(handle,24,104,"Name :");
  1194.  v_gtext(handle,24,112,"Align:");
  1195.  v_gtext(handle,24,120,"Class:");
  1196.  v_gtext(handle,24,128,"A.C. :");
  1197.  v_gtext(handle,24,136,"Lvl. :");
  1198.  v_gtext(handle,24,174,"Weapon:");
  1199.  v_gtext(handle,24,184,"Armour:"); 
  1200.  v_gtext(handle,24,196,"Location:");
  1201.  v_gtext(handle,96,196,"The City    ");
  1202.  v_gtext(handle,78,174,user.weapon);   
  1203.  v_gtext(handle,79,184,user.armor);
  1204.  v_gtext(handle,24,144,"STR. :");
  1205.  v_gtext(handle,24,152,"INT. :");
  1206.  v_gtext(handle,24,160,"DEX. :");
  1207.  v_gtext(handle,204,110,"Realtime:");
  1208.  v_gtext(handle,204,156,"S.P.:");
  1209.  v_gtext(handle,204,148,"H.P.:");   
  1210.  v_gtext(handle,204,180,"Weather");
  1211. */
  1212. }
  1213.  
  1214.  
  1215. /******************************************/
  1216. /* will display the street you are on 
  1217.    searches the intersection[max].room array for the room you are currently in
  1218.    if found then display new street
  1219.   
  1220.    room currntly in : = map[room].room;
  1221.    max == 35*/
  1222.  
  1223. display_street()
  1224. {
  1225.  int cell,max,counter;
  1226.  int not_found=1;        /* initally set to 1 */
  1227.  
  1228.    cell = map[room].room;
  1229.     max = 35;                  /* max search limit */
  1230.      counter = 0;
  1231.  
  1232.      while( (counter < max) && (not_found)) /* loop until found or search entire array */
  1233.        {
  1234.         if (cell == intersection[counter].room)
  1235.            { not_found = 0;    /* set to false, we found it */
  1236.              v_gtext(handle,197,99,intersection[counter].street_name); 
  1237.              strcpy(street_hold,intersection[counter].street_name);
  1238.             /* save the street name */
  1239.              
  1240.            }
  1241.         counter++;
  1242.        }
  1243. }
  1244.  
  1245. /**********/
  1246. off()
  1247. {
  1248.  char *conterm;
  1249.  
  1250.  conterm = (char *) 0x484L;
  1251.  *conterm &=0xFE;   /* turn lsb off */
  1252. }
  1253.  
  1254. /***********/
  1255. /* help user: Displays help info to the user */
  1256. help_user()
  1257. {
  1258.   
  1259.  
  1260. v_gtext(handle,6,11,"    ~ Help Options ~ ");
  1261. v_gtext(handle,6,27,"Up    Arrow -Go forward");
  1262. v_gtext(handle,6,35,"Right Arrow -Turn right");
  1263. v_gtext(handle,6,43,"Left  Arrow -Turn left");
  1264. v_gtext(handle,6,51,"P     Key   -Pause    ");
  1265. v_gtext(handle,6,59,"I     Key   -User Info");
  1266. v_gtext(handle,6,85,"Press any key");
  1267. user_pause();
  1268.  
  1269. v_gtext(handle,6,19,"    ~ Help Options ~ ");
  1270. v_gtext(handle,6,35,"F1   Key -Switch Weapon");
  1271. v_gtext(handle,6,43,"G    Key -Game Options");
  1272. v_gtext(handle,6,51,"U    Key -User Items");
  1273. v_gtext(handle,6,59,"T    Key -Check time");
  1274. v_gtext(handle,6,67,"Help Key -This Menu");
  1275.  
  1276. v_gtext(handle,6,83,"Press any key");
  1277.  
  1278. }
  1279.  
  1280. /*********/
  1281. /* user_pause: Waits until user hits a key before returning.. */
  1282.  
  1283. user_pause()
  1284. {
  1285.  char hh;
  1286.  
  1287.   hh = Bconin(2);
  1288. }
  1289.  
  1290.  
  1291. /*****************/
  1292. /* new pic code */
  1293. /*****************************/
  1294. /* returns source pxyarray for 
  1295.       Dungeon templates 
  1296. #define MF3211        12
  1297. #define MF3212        13
  1298. #define MF1611        14
  1299. #define MF1612        15
  1300. #define MF641        16
  1301. #define FF3211        17
  1302. #define FF3212        18
  1303. #define FF1611        19
  1304. #define FF1612        20
  1305. #define FF641        21
  1306. #define MF3221        22    
  1307. #define MF3222        23
  1308. #define MF1621        24
  1309. #define MF1622        25
  1310. #define MF642        26
  1311. #define FF3221        27
  1312. #define FF3222        28
  1313. #define FF1621        29
  1314. #define FF1622        30
  1315. #define FF642        31
  1316.  
  1317. */
  1318.  
  1319.  getcoord(Field ,pxyarray,mfs,scr1,scr2,scr3,scr4,scr7)       
  1320.  int Field,pxyarray[8];
  1321.  register MFDB *mfs;
  1322.  char *scr1,*scr2,*scr3,*scr4,*scr7;
  1323.  
  1324.  
  1325.  
  1326. {
  1327.  
  1328. char ccc;
  1329.  
  1330. mfs->fd_addr = (long) scr1;  /* most of the templates are in scr1 */
  1331.                              /* but FL and Fr are on scr2 */
  1332.  
  1333. mode = OR;  /* default setting of vrocopyfm mode */
  1334.  
  1335.   switch(Field)
  1336.     {
  1337.      case CF64: pxyarray[0] = 188; pxyarray[1] = 3; pxyarray[2] = 251; pxyarray[3] = 138; mode =REPLACE; break;
  1338.      case CL: pxyarray[0] = 36; pxyarray[1] = 3; pxyarray[2] = 67; pxyarray[3] = 138; break;
  1339.      case ML: pxyarray[0] = 69; pxyarray[1] = 3; pxyarray[2] = 100; pxyarray[3] = 138; break;
  1340.      case CF1: pxyarray[0] = 188; pxyarray[1] = 3; pxyarray[2] = 219; pxyarray[3] = 138; mode =REPLACE; break;
  1341.      case CF2: pxyarray[0] = 220; pxyarray[1] = 3; pxyarray[2] = 251; pxyarray[3] = 138; mode =REPLACE; break;
  1342.      case CF1_SPECIAL: pxyarray[0] = 188; pxyarray[1] = 3; pxyarray[2] = 203; pxyarray[3] = 138; mode =REPLACE;break;
  1343.      case CF2_SPECIAL: pxyarray[0] = 236; pxyarray[1] = 3; pxyarray[2] = 251; pxyarray[3] = 138; mode =REPLACE;break;    
  1344.      case ML_GATE: pxyarray[0] = 120; pxyarray[1] = 3; pxyarray[2] = 151; pxyarray[3] = 138; break;
  1345.      case MR_GATE: pxyarray[0] = 153; pxyarray[1] = 3; pxyarray[2] = 186; pxyarray[3] = 138; break;
  1346.      case FL_GATE: pxyarray[0] = 102; pxyarray[1] = 3; pxyarray[2] = 117; pxyarray[3] = 138; break;
  1347.    
  1348.      case MF3211: pxyarray[0] = 254; pxyarray[1] = 3; pxyarray[2] = 285; pxyarray[3] = 138; mode =REPLACE;break;
  1349.      case MF3212: pxyarray[0] = 286; pxyarray[1] = 3; pxyarray[2] = 317; pxyarray[3] = 138; mode =REPLACE;break;    
  1350.      case MF1611: pxyarray[0] = 1; pxyarray[1] = 3; pxyarray[2] = 16; pxyarray[3] = 138; mode =REPLACE;break;
  1351.      case MF1612: pxyarray[0] = 19; pxyarray[1] = 3; pxyarray[2] = 34; pxyarray[3] = 138; mode =REPLACE;break;    
  1352.  
  1353.  
  1354.       /* SCR2 PICS */
  1355. case CR: pxyarray[0] = 281; pxyarray[1] = 6; pxyarray[2] = 312; pxyarray[3] = 141; mfs->fd_addr = (long) scr2; break;
  1356. case MR: pxyarray[0] = 248; pxyarray[1] = 6; pxyarray[2] = 279; pxyarray[3] = 141; mfs->fd_addr = (long) scr2; break;
  1357. case FR: pxyarray[0] = 0; pxyarray[1] = 6; pxyarray[2] = 15; pxyarray[3] = 141; mfs->fd_addr = (long) scr2; break;
  1358. case FL: pxyarray[0] = 16; pxyarray[1] = 6; pxyarray[2] = 31; pxyarray[3] = 141; mfs->fd_addr = (long) scr2; break;
  1359. case FR_GATE: pxyarray[0] = 230; pxyarray[1] = 6; pxyarray[2] = 245; pxyarray[3] = 141; mfs->fd_addr = (long) scr2; break;
  1360. case REG_R4_FILL: pxyarray[0] = 140; pxyarray[1] = 6; pxyarray[2] = 203; pxyarray[3] = 141; mfs->fd_addr = (long) scr2; mode =REPLACE;break;
  1361. case REG_FAR_FILL: pxyarray[0] = 206; pxyarray[1] = 6; pxyarray[2] = 221; pxyarray[3] = 141; mfs->fd_addr = (long) scr2;mode =REPLACE; break;
  1362. case REG_MED_CLOSE_FILL: pxyarray[0] = 103; pxyarray[1] = 6; pxyarray[2] = 134; pxyarray[3] = 141; mfs->fd_addr = (long) scr2;mode =REPLACE; break;
  1363. case MF641: pxyarray[0] = 140; pxyarray[1] = 6; pxyarray[2] = 203; pxyarray[3] = 141; mfs->fd_addr = (long) scr2;mode =REPLACE; break;
  1364. case FF3211: pxyarray[0] = 34; pxyarray[1] = 6; pxyarray[2] = 65; pxyarray[3] = 141; mfs->fd_addr = (long) scr2;mode =REPLACE;break;
  1365. case FF3212: pxyarray[0] = 66; pxyarray[1] = 6; pxyarray[2] = 97; pxyarray[3] = 141; mfs->fd_addr = (long) scr2;mode =REPLACE;break;    
  1366.  
  1367. /*SCR3 PICS */
  1368.  
  1369. case FF1611: pxyarray[0] = 72; pxyarray[1] = 6; pxyarray[2] = 87; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;
  1370. case FF1612: pxyarray[0] = 89; pxyarray[1] = 6; pxyarray[2] = 104; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;    
  1371. case FF641: pxyarray[0] = 6; pxyarray[1] = 6; pxyarray[2] = 69; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;
  1372. case MF3221: pxyarray[0] = 106; pxyarray[1] = 6; pxyarray[2] = 137; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;    
  1373. case MF3222: pxyarray[0] = 139; pxyarray[1] = 6; pxyarray[2] = 170; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;
  1374. case MF1621: pxyarray[0] = 172; pxyarray[1] = 6; pxyarray[2] = 187; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;    
  1375. case MF1622: pxyarray[0] = 189; pxyarray[1] = 6; pxyarray[2] = 204; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;    
  1376. case MF642: pxyarray[0] = 206; pxyarray[1] = 6; pxyarray[2] = 269; pxyarray[3] = 141; mfs->fd_addr = (long) scr3;mode =REPLACE;break;    
  1377.  
  1378.  
  1379. /* SCREEN 4 PICS */
  1380. case FF3221: pxyarray[0] = 6; pxyarray[1] = 2; pxyarray[2] = 37; pxyarray[3] = 137; mfs->fd_addr = (long) scr4;mode =REPLACE;break;
  1381. case FF3222: pxyarray[0] = 38; pxyarray[1] = 2; pxyarray[2] = 69; pxyarray[3] = 137; mfs->fd_addr = (long) scr4;mode =REPLACE;break;
  1382. case FF1621: pxyarray[0] = 71; pxyarray[1] = 2; pxyarray[2] = 86; pxyarray[3] = 137; mfs->fd_addr = (long) scr4;mode =REPLACE;break;
  1383. case FF1622: pxyarray[0] = 88; pxyarray[1] = 2; pxyarray[2] = 103; pxyarray[3] = 137; mfs->fd_addr = (long) scr4;mode =REPLACE;break;
  1384. case FF642: pxyarray[0] = 105; pxyarray[1] = 2; pxyarray[2] = 168; pxyarray[3] = 137; mfs->fd_addr = (long) scr4;mode =REPLACE;break;
  1385.  
  1386.  
  1387.  
  1388.     }
  1389.  
  1390. }
  1391. /*****************************/
  1392.  
  1393. display(mfd,mfs,pxyarray,scr1,scr2,scr3,scr4,scr5,scr6,scr7,backgroundMFDB)
  1394. register MFDB *mfd,*mfs,*backgroundMFDB;
  1395. int pxyarray[8];
  1396. char *scr1,*scr2,*scr3,*scr4,*scr5,*scr6,*scr7;
  1397.  
  1398. {
  1399. int check_for_new_pal,
  1400.     facing = 0;
  1401. char tyee;
  1402.  
  1403.  
  1404. a_hidemouse();
  1405.  
  1406.   
  1407.     
  1408.   /* SET the mfs  MFDB dest!!! */
  1409.      Setscreen(back,screen,-1); /* back is logical, screen is physical */
  1410.      mfd->fd_addr = (long)back; /*set dest to be back screen*/
  1411.  
  1412.  
  1413.   /* erase the backscreen movement area */
  1414.    
  1415.          vsf_color(handle,0);
  1416.          vr_recfl(handle,rect1); 
  1417.  
  1418.  
  1419.                 /* find the direction we're facing and display
  1420.                    approrate floor */
  1421.  
  1422.      /* set the dest for the floor */
  1423.      pxyarray[4]=7; pxyarray[5]=9;  /* x coords only, y does not change at all */
  1424.      pxyarray[6]=230; pxyarray[7]=144; 
  1425. switch(dir)
  1426.  {
  1427.    case 'N': floor=roomrec[room].N.floor; break;
  1428.    case 'S': floor=roomrec[room].S.floor; break;
  1429.    case 'E': floor=roomrec[room].E.floor; break;
  1430.    case 'W': floor=roomrec[room].W.floor; break;
  1431.  }
  1432.  
  1433. /* draw the floor first 
  1434.    if floor == 0 use floor1 (scr5) 
  1435.    if floor == 1 use floor2 (scr6)    */
  1436.    
  1437.    if(!floor)        /* that is, if floor == 0 */
  1438.      {
  1439.       mfs->fd_addr = (long)scr5;
  1440.       pxyarray[0] = 42; pxyarray[1]=22; pxyarray[2]=265; pxyarray[3]=157;            
  1441.      }
  1442.    if(floor)   /* that is, if == 1 */
  1443.      {
  1444.       mfs->fd_addr = (long)scr6;  /* holds floor 2 */
  1445.       pxyarray[0] = 47; pxyarray[1]=23; pxyarray[2]=270; pxyarray[3]=158;          
  1446.      }
  1447.      vro_cpyfm(handle,3,pxyarray,mfs,mfd);  /* display it */ 
  1448.  
  1449.     
  1450.  
  1451. /* reset starting destination coords */
  1452.     pxyarray[4] = 7;   /* Reset dest starting coords. for the 6 regions... */
  1453.                        /* just reset the x positions 4,6 cause y pos will stay same */
  1454.     pxyarray[6] = 38;
  1455.     pxyarray[5] = 9; pxyarray[7] = 144;  
  1456.  
  1457.  /* reset default mfdb source */
  1458.    mfs->fd_addr = (long)scr1;  /* holds all templates BUT FL,FR */
  1459.  
  1460. /* all drawing will be done in the BACK screen, then we'll swap 
  1461.    the back to the front */
  1462.             
  1463.   switch(dir)
  1464.  
  1465.     {
  1466.      case  'N' : {
  1467.         /* vrocopy the 7 regions
  1468.          pxyarray[4-7] is the dest.
  1469.          pxyarray[4] & pxyarray[6] need to be inc by delta 
  1470.          after each vrocopy is called for a region:
  1471.          region 1 = 32 pixels    
  1472.                r2 = 32  \
  1473.                r3 = 16   \ DELTA     
  1474.                r4 = 64   / 
  1475.                r5 = 16  /
  1476.                r6 = 32 /
  1477.                r7 = 32/
  1478.          pxyarray[5]& [7] are constant.
  1479.    
  1480.          */
  1481.    /**
  1482.       roomrec has an entry for each room
  1483.        1. to access that entry use the 'room' global variable
  1484.           as an index into roomrec[].<Filedx>
  1485.    **/
  1486.        /* region 1 */
  1487.        
  1488.        getcoord(roomrec[room].N.Field1,pxyarray,mfs,scr1,scr2,scr3,scr4); /* returns source pxyarray */
  1489.        if(roomrec[room].N.Field1 != EMPTY) /* that is, if !Empty ..then copy */
  1490.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1491.    
  1492.        /*region 2 */        
  1493.        pxyarray[4] += 32;   /* dest */
  1494.        pxyarray[6] += 32;
  1495.        getcoord(roomrec[room].N.Field2,pxyarray,mfs,scr1,scr2,scr3,scr4); /* returns source pxyarray */
  1496.        if(roomrec[room].N.Field2 != EMPTY) /* that is, if !Empty ..then copy */
  1497.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1498.    
  1499.         /*region 3 */
  1500.        pxyarray[4] += 32;   /* dest */
  1501.        pxyarray[6] += 16;  /* sets up region 3 coords */
  1502.        getcoord(roomrec[room].N.Field3,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1503.        if(roomrec[room].N.Field3 != EMPTY) /* that is, if !Empty ..then copy */
  1504.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1505.        
  1506.         /*region 5 */
  1507.        pxyarray[4] += 64+16;   /* dest */
  1508.        pxyarray[6] += 16+64;   /* sets up region 5 dest */
  1509.        getcoord(roomrec[room].N.Field5,pxyarray,mfs,scr1,scr2,scr3,scr4); /* returns source pxyarray */
  1510.        if(roomrec[room].N.Field5 != EMPTY) /* that is, if !Empty ..then copy */
  1511.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1512.        
  1513.        /*region 6 */
  1514.        pxyarray[4] += 16;   /* dest */
  1515.        pxyarray[6] += 32;
  1516.        getcoord(roomrec[room].N.Field6,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1517.        if(roomrec[room].N.Field6 != EMPTY) /* that is, if !Empty ..then copy */
  1518.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1519.  
  1520.        /* region 7 */
  1521.        pxyarray[4] += 32;   /* dest */
  1522.        pxyarray[6] += 32;
  1523.        getcoord(roomrec[room].N.Field7,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1524.        if(roomrec[room].N.Field7 != EMPTY) /* that is, if !Empty ..then copy */
  1525.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1526.  
  1527.         
  1528.         /*region 4 */
  1529.        pxyarray[4] -= 32+16+64;   /* dest */
  1530.        pxyarray[6] -= 32+32+16;   /* sets up region 4 dest */
  1531.        getcoord(roomrec[room].N.Field4,pxyarray,mfs,scr1,scr2,scr3,scr4); /* returns source pxyarray */
  1532.        if(roomrec[room].N.Field4 == FAR_GATE || roomrec[room].N.Field4 == CLOSE_GATE)
  1533.         show_gate(mfs,mfd,pxyarray,scr4,scr7,scr1,roomrec[room].N.Field4,back,backgroundMFDB);
  1534.        else if(roomrec[room].N.Field4 != EMPTY) /* that is, if !Empty ..then copy */
  1535.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1536.            
  1537.  
  1538.            break;
  1539.      }   
  1540.     
  1541.      case 'S' : {
  1542.             /* region 1 */
  1543.       
  1544.        getcoord(roomrec[room].S.Field1,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1545.        if(roomrec[room].S.Field1 != EMPTY) /* that is, if !Empty ..then copy */
  1546.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1547.  
  1548.  
  1549.        /*region 2 */
  1550.        pxyarray[4] += 32;   /* dest */
  1551.        pxyarray[6] += 32;
  1552.        getcoord(roomrec[room].S.Field2,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1553.        if(roomrec[room].S.Field2 != EMPTY) /* that is, if !Empty ..then copy */
  1554.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1555.  
  1556.         /*region 3 */
  1557.        pxyarray[4] += 32;   /* dest */
  1558.        pxyarray[6] += 16;
  1559.        getcoord(roomrec[room].S.Field3,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1560.        if(roomrec[room].S.Field3 != EMPTY) /* that is, if !Empty ..then copy */
  1561.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */       
  1562.  
  1563.         /*region 5 */
  1564.        pxyarray[4] += 64+16;   /* dest */
  1565.        pxyarray[6] += 16+64;
  1566.        getcoord(roomrec[room].S.Field5,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1567.        if(roomrec[room].S.Field5 != EMPTY) /* that is, if !Empty ..then copy */
  1568.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1569.        
  1570.        /*region 6 */
  1571.        pxyarray[4] += 16;   /* dest */
  1572.        pxyarray[6] += 32;
  1573.        getcoord(roomrec[room].S.Field6,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1574.        if(roomrec[room].S.Field6 != EMPTY) /* that is, if !Empty ..then copy */
  1575.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1576.  
  1577.        /* region 7 */
  1578.        pxyarray[4] += 32;   /* dest */
  1579.        pxyarray[6] += 32;
  1580.        getcoord(roomrec[room].S.Field7,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1581.        if(roomrec[room].S.Field7 != EMPTY) /* that is, if !Empty ..then copy */
  1582.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1583.  
  1584.        
  1585.         /*region 4 */
  1586.        pxyarray[4] -= 32+16+64;   /* dest */
  1587.        pxyarray[6] -= 32+32+16;
  1588.        getcoord(roomrec[room].S.Field4,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1589.        if(roomrec[room].S.Field4 == FAR_GATE || roomrec[room].S.Field4 == CLOSE_GATE)
  1590.         show_gate(mfs,mfd,pxyarray,scr4,scr7,scr1,roomrec[room].S.Field4,back,backgroundMFDB);
  1591.  
  1592.       else if(roomrec[room].S.Field4 != EMPTY) /* that is, if !Empty ..then copy */
  1593.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1594.  
  1595.  
  1596.           break;
  1597.                 }   
  1598.      case 'E' : {
  1599.              /* region 1 */
  1600.       
  1601.        getcoord(roomrec[room].E.Field1,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1602.        if(roomrec[room].E.Field1 != EMPTY) /* that is, if !Empty ..then copy */
  1603.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1604.  
  1605.        /*region 2 */
  1606.        pxyarray[4] += 32;   /* dest */
  1607.        pxyarray[6] += 32;
  1608.        getcoord(roomrec[room].E.Field2,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1609.        if(roomrec[room].E.Field2 != EMPTY) /* that is, if !Empty ..then copy */
  1610.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1611.  
  1612.         /*region 3 */
  1613.        pxyarray[4] += 32;   /* dest */
  1614.        pxyarray[6] += 16;
  1615.        getcoord(roomrec[room].E.Field3,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1616.        if(roomrec[room].E.Field3 != EMPTY) /* that is, if !Empty ..then copy */
  1617.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1618.        
  1619.         /*region 5 */
  1620.        pxyarray[4] += 64+16;   /* dest */
  1621.        pxyarray[6] += 16+64;
  1622.        getcoord(roomrec[room].E.Field5,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1623.        if(roomrec[room].E.Field5 != EMPTY) /* that is, if !Empty ..then copy */
  1624.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1625.        
  1626.        /*region 6 */
  1627.        pxyarray[4] += 16;   /* dest */
  1628.        pxyarray[6] += 32;
  1629.        getcoord(roomrec[room].E.Field6,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1630.        if(roomrec[room].E.Field6 != EMPTY) /* that is, if !Empty ..then copy */
  1631.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1632.     
  1633.        /* region 7 */
  1634.        pxyarray[4] += 32;   /* dest */
  1635.        pxyarray[6] += 32;
  1636.        getcoord(roomrec[room].E.Field7,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1637.        if(roomrec[room].E.Field7 != EMPTY) /* that is, if !Empty ..then copy */
  1638.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1639.  
  1640.       
  1641.         /*region 4 */
  1642.        pxyarray[4] -= 32+16+64;   /* dest */
  1643.        pxyarray[6] -= 32+32+16;
  1644.        getcoord(roomrec[room].E.Field4,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1645.        if(roomrec[room].E.Field4 == FAR_GATE || roomrec[room].E.Field4 == CLOSE_GATE)
  1646.         show_gate(mfs,mfd,pxyarray,scr4,scr7,scr1,roomrec[room].E.Field4,back,backgroundMFDB);
  1647.  
  1648.        else if(roomrec[room].E.Field4 != EMPTY) /* that is, if !Empty ..then copy */
  1649.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1650.  
  1651.  
  1652.            break;
  1653.                 }      
  1654.      case 'W' : 
  1655.       {
  1656.        /* region 1 */
  1657.       
  1658.        getcoord(roomrec[room].W.Field1,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1659.        if(roomrec[room].W.Field1 != EMPTY) /* that is, if !Empty ..then copy */
  1660.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1661.  
  1662.        /*region 2 */
  1663.        pxyarray[4] += 32;   /* dest */
  1664.        pxyarray[6] += 32;
  1665.        getcoord(roomrec[room].W.Field2,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1666.        if(roomrec[room].W.Field2 != EMPTY) /* that is, if !Empty ..then copy */
  1667.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1668.  
  1669.         /*region 3 */
  1670.        pxyarray[4] += 32;   /* dest */
  1671.        pxyarray[6] += 16;
  1672.        getcoord(roomrec[room].W.Field3,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1673.        if(roomrec[room].W.Field3 != EMPTY) /* that is, if !Empty ..then copy */
  1674.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1675.        
  1676.         /*region 5 */
  1677.        pxyarray[4] += 64+16;   /* dest */
  1678.        pxyarray[6] += 16+64;
  1679.        getcoord(roomrec[room].W.Field5,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1680.        if(roomrec[room].W.Field5 != EMPTY) /* that is, if !Empty ..then copy */
  1681.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1682.        
  1683.        /*region 6 */
  1684.        pxyarray[4] += 16;   /* dest */
  1685.        pxyarray[6] += 32;
  1686.        getcoord(roomrec[room].W.Field6,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1687.        if(roomrec[room].W.Field6 != EMPTY) /* that is, if !Empty ..then copy */
  1688.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1689.  
  1690.       /* region 7 */
  1691.        pxyarray[4] += 32;   /* dest */
  1692.        pxyarray[6] += 32;
  1693.        getcoord(roomrec[room].W.Field7,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1694.        if(roomrec[room].W.Field7 != EMPTY) /* that is, if !Empty ..then copy */
  1695.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1696.  
  1697.        
  1698.         /*region 4 */
  1699.        pxyarray[4] -= 32+16+64;   /* dest */
  1700.        pxyarray[6] -= 32+32+16;
  1701.        getcoord(roomrec[room].W.Field4,pxyarray,mfs,scr1,scr2,scr3,scr4  ); /* returns source pxyarray */
  1702.        if(roomrec[room].W.Field4 == FAR_GATE || roomrec[room].W.Field4 == CLOSE_GATE)
  1703.         show_gate(mfs,mfd,pxyarray,scr4,scr7,scr1,roomrec[room].W.Field4,back,backgroundMFDB);
  1704.  
  1705.      else if(roomrec[room].W.Field4 != EMPTY) /* that is, if !Empty ..then copy */
  1706.        vro_cpyfm(handle,mode,pxyarray,mfs,mfd);  /* copy wholescreens */
  1707.  
  1708.        
  1709.        break;
  1710.        }
  1711.  
  1712.    }  /*end of switch*/  
  1713.  
  1714.   temp = screen;
  1715.   screen = back;
  1716.   back = temp;
  1717.   Vsync();
  1718.   Setscreen(screen,screen,-1);   /*now display it! */
  1719.   a_showmouse();
  1720.  
  1721.   /* color which key was pressed */
  1722.   display_pressed_key(15);   /* send it the white color */
  1723.   pause(8);
  1724.   display_pressed_key(0);    /* then send it the back color */
  1725. }
  1726.  
  1727. /********************/
  1728. display_pressed_key(colo)
  1729. int colo;
  1730. {
  1731.  int x99,y99;
  1732.  
  1733.  
  1734.      if(command == FOREWARD){ x99=276; y99=117;}
  1735.       else if(command == BACK){x99=276; y99=136;}
  1736.       else if(command == TURN_LEFT){x99=252; y99=117;}    
  1737.       else if(command == TURN_RIGHT){x99=299; y99=117; }  
  1738.       else if(command == LEFT){      x99=252; y99=136;  } 
  1739.       else if(command == RIGHT){     x99=299; y99=136;   }
  1740.       
  1741.  
  1742.   if(command !=NOTHING)
  1743.   {
  1744.     vsf_color(handle,colo);  /*seed fill color  */
  1745.     v_contourfill(handle,x99,y99,-1);
  1746.   } 
  1747. }
  1748.  
  1749.  
  1750. /***/
  1751. pause(time)
  1752. int time;
  1753. {
  1754.  int tsec;
  1755.  
  1756.    for(tsec=0;tsec<time;tsec++)
  1757.      Vsync();
  1758. }
  1759.  
  1760.  
  1761. /***************************/
  1762. /* display gate pic
  1763.  
  1764.     1. set pxyarray
  1765.     2. do copy
  1766.     3. reset pxyarray
  1767. */
  1768.  
  1769.  show_gate(mfs,mfd,pxyarray,scr4,scr7,scr1,GATE_TYPE,back,backgroundMFDB)
  1770.  int GATE_TYPE;
  1771.  MFDB *mfs,*mfd,*backgroundMFDB;
  1772.  int pxyarray[];
  1773.  char *scr4,*scr7,*scr1,*back;
  1774. {
  1775.  int holdcoords[4];
  1776.  int h;
  1777.  
  1778. /*
  1779.   for(h=0;h<4;h++)
  1780.     holdcoords[h] = pxyarray[h+4];
  1781. */
  1782.  
  1783. if(GATE_TYPE == FAR_GATE )
  1784.   {
  1785.     /* copy mask and template */
  1786.     mfs->fd_addr = (long) scr4;
  1787.  
  1788.    /* set new DEST coords */
  1789.     pxyarray[4] = 86; pxyarray[5] = 42; pxyarray[6] = 151; pxyarray[7] = 88; 
  1790.  
  1791.     pxyarray[0] = 170; pxyarray[1] = 2; pxyarray[2] = 235; pxyarray[3] = 48; 
  1792.     vro_cpyfm(handle,4,pxyarray,mfs,mfd);  /* copy wholescreens */
  1793.     pxyarray[0] = 237; pxyarray[1] = 2; pxyarray[2] = 302; pxyarray[3] = 48; 
  1794.     vro_cpyfm(handle,7,pxyarray,mfs,mfd);  /* copy wholescreens */
  1795.   
  1796.   } 
  1797.  else /* its a close gate */
  1798.   {
  1799.      mfs->fd_addr = (long) back;  /* lets copy what will be behind gate */
  1800.       /* source coords */
  1801.      pxyarray[0]=71; pxyarray[1]=31; pxyarray[2]=166; pxyarray[3]=112;    
  1802.      /* dest coords  */
  1803.      pxyarray[4]=71; pxyarray[5]=31; pxyarray[6]=166; pxyarray[7]=112;    
  1804.      /* do the copy: theMFDB is the SOURCE, backgroundMFDB is the dest*/
  1805.      vro_cpyfm(handle,REPLACE,pxyarray,mfs,backgroundMFDB);     
  1806.  
  1807.  
  1808.     /* copy mask and template */
  1809.     mfs->fd_addr = (long) scr7;
  1810.  
  1811.      pxyarray[4] = 71;                /* the destination coords */
  1812.      pxyarray[6] = 166;
  1813.      pxyarray[5] = 32; pxyarray[7]=112;
  1814.  
  1815.      pxyarray[0]=0; pxyarray[1]=0; pxyarray[2]=95; pxyarray[3]=79;
  1816.     vro_cpyfm(handle,4,pxyarray,mfs,mfd);  /* copy wholescreens */
  1817.     pxyarray[0]=96; pxyarray[1]=0; pxyarray[2]=190; pxyarray[3]=79;
  1818.     vro_cpyfm(handle,7,pxyarray,mfs,mfd);  /* copy wholescreens */  
  1819.   }
  1820.  
  1821.  
  1822.  
  1823. /* reset starting destination coords */
  1824.  
  1825. /*
  1826.  for(h=0;h<4;h++)
  1827.     pxyarray[h+4]=holdcoords[h];
  1828. */
  1829.  
  1830. }
  1831.